package com.kws.commercial.controller;

import com.github.pagehelper.PageInfo;
import com.kws.commercial.dao.Info.QueryCommercialSignatureInfo;
import com.kws.commercial.dao.Rq.CreateCommercialSignatureRq;
import com.kws.commercial.dao.Rq.UpdateCommercialSignatureRq;
import com.kws.commercial.service.CommercialSignatureManageService;
import com.kws.common.core.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <b>CommercialSignatureController</b>
 *
 * @description: CommercialSignatureController <br>
 * @date: 2024/10/24 15:17 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "签名管理")
@RestController
public class CommercialSignatureController {
    private static final Logger logger = LoggerFactory.getLogger(CommercialSignatureController.class);

    @Autowired
    private CommercialSignatureManageService commercialSignatureManageService;

    @ApiOperation("分页查询签名列表")
    @GetMapping("/query/commercialSignature/page")
    public R<PageInfo<QueryCommercialSignatureInfo>> queryCommercialSignaturePage(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                                                                  @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
                                                                                  @RequestParam(required = false) String signatureHolder) {
        PageInfo<QueryCommercialSignatureInfo> pageInfo = commercialSignatureManageService.queryCommercialSignaturePage(pageNum,pageSize,signatureHolder);
        return R.ok(pageInfo);
    }

    @ApiOperation("创建签名")
    @PostMapping("/create/commercialSignature")
    public R createCommercialSignature(@RequestBody CreateCommercialSignatureRq rq){
        boolean status = commercialSignatureManageService.createCommercialSignature(rq);
        return R.ok(status);
    }

    @ApiOperation("根据签名ID查询签名详情")
    @GetMapping("/query/commercialSignature/info")
    public R<QueryCommercialSignatureInfo> queryCommercialSignatureInfo(@RequestParam Long id){
        QueryCommercialSignatureInfo info = commercialSignatureManageService.queryCommercialSignatureInfo(id);
        return R.ok(info);
    }

    @ApiOperation("根据签名ID修改签名信息")
    @PostMapping("/update/commercialSignature/byId")
    public R updateCommercialSignatureById(@RequestBody UpdateCommercialSignatureRq rq){
        boolean status = commercialSignatureManageService.updateCommercialSignatureById(rq);
        return R.ok(status);
    }

    @ApiOperation("根据签名ID删除签名信息")
    @PostMapping("/delete/commercialSignature/byId")
    public R deleteCommercialSignatureById(@RequestBody List<Long> ids){
        boolean status = commercialSignatureManageService.deleteCommercialSignatureById(ids);
        return R.ok(status);
    }
}
